package com.hrt.web.comments.service.Impl;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hrt.bean.Replys;
import com.hrt.web.comments.dao.ReplysWebDao;
import com.hrt.web.comments.service.ReplysWebService;

@Transactional
@Service("ReplysWebService")
public class ReplysWebServiceImpl implements ReplysWebService{
	
	@Autowired
	private ReplysWebDao replysDao;
	
	/**
	 * 保存实体
	 * */
	@Override
	public void addReplys(Replys Replys) {
		this.replysDao.saveEntity(Replys);
	}

	/**
	 * 更新实体
	 * */
	@Override
	public void updateReplys(Replys Replys) {
		this.replysDao.updateEntity(Replys);
	}

	/**
	 * 删除实体
	 * */
	@Override
	public void delReplys(Long id) {
		this.replysDao.deleteEntity(id);
	}

	/**
	 * 按id查询实体
	 * */
	@Override
	public Replys getById(Long id) {
		
		return this.replysDao.getById(id);
	}

	/**
	 * 查询所有
	 * */
	@Override
	public List<Replys> searchAll() {
		
		return this.replysDao.findAll();
	}

	/**
	 * 按是否删除查询
	 */
	@Override
	public List<Replys> searchDelAll() {
		
		return this.replysDao.findDelAll();
	}

	/**
	 * 按id列表查询实体
	 * */
	@Override
	public List<Replys> getByIds(Long[] ids) {
		
		return this.replysDao.getByIds(ids);
	}

	/**分页*/
	@Override
	public Long totalCount() {
		
		return this.replysDao.totalCount();
	}
	@Override
	public List<Replys> queryByPage(int pageIndex, int pageSize) {
		
		return this.replysDao.queryByPage(pageIndex, pageSize);
	}

	/**获取数据库的当前Timestamp形式的时间*/
	@Override
	public Timestamp getDate() {
		return this.replysDao.getDate();
	}

	/**删除选中的数据*/
	@Override
	public void deleteById(Long[] ids) throws Exception {
		List<Replys> delResult = this.replysDao.getByIds(ids);
		for (Replys  comm: delResult) {
			comm.setIsdelete(new Integer(1));
			this.replysDao.updateEntity(comm);
		}
	}

}
